﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;

namespace ShopPowerTemplate.Common
{
    public sealed class RatingMultiplierConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            double doubleVal = Double.Parse(value.ToString());

            return ofMap(doubleVal, 0, 5, 0, 5);
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            double doubleVal = Double.Parse(value.ToString());

            return ofMap(doubleVal, 0, 5, 0, 5);
        }

        double ofMap(double value, double inputMin, double inputMax, double outputMin, double outputMax)
        {
            return ((value - inputMin) / (inputMax - inputMin) * (outputMax - outputMin) + outputMin);
        }
    }
}
